#ifndef __SMS_SLISTVIEW__
#define __SMS_SLISTVIEW__

#include <goocanvas.h>
#include "theme.h"

#define SLISTVIEW_ANI_DURATION 300
#define SLISTVIEW_ANI_STEP	50

typedef struct _SListIter SListIter;
typedef struct _SListMethod SListMethod;
typedef struct _SListView SListView;

struct _SListIter
{
	SListIter *prv;
	SListIter *next;
	GooCanvasItem *cavas;
	gboolean highlight;
	gpointer private;
};

struct _SListMethod
{
	SListIter *(*slistmethod_create_iter)(SListView *view, ...);
	void (*slistmethod_destroy_iter)(SListIter *iter);
	gboolean (*slistmethod_get_iter_property)(SListIter *iter,const char *property,gpointer);
	gboolean (*slistmethod_set_iter_property)(SListIter *iter,const char *property,gpointer);
	gboolean (*slistmethod_highlight_iter)(SListIter *iter,gboolean highlight);
};

struct _SListView
{
	GooCanvasItem *parent;
	GooCanvasItem *cavas;
	GooCanvasItem *frame;
	GooCanvasItem *background;
	GooCanvasItem *highlight;
	GooCanvasItem *up;
	GooCanvasItem *down;

	int x;
	int y;
	int width;
	int height;
	int item_height;
	int item_border;

	int view_cur;
	int view_count;
	int list_cur;
	int list_count;
	
	int ani_duration;
	int ani_step;
	
	gboolean active;

	SListIter *head;
	SListIter *tail;
	SListIter *cur_iter;

	SListMethod *method;
	Theme *theme;
};

SListView *slistview_new(GooCanvasItem *parent,int x,int y,int width,int item_height,int item_border,int view_count,Theme *theme);
void slistview_destroy(SListView *view);
void slistview_clear_list(SListView *view);
void slistview_set_method(SListView *view,SListMethod *method);
SListMethod* slistview_get_method(SListView *view);
void slistview_set_pic(SListView *view,GdkPixbuf *bg,GdkPixbuf *hl,GdkPixbuf *up,GdkPixbuf *down);
void slistview_set_pic_by_theme(SListView *view);

gboolean slistview_scroll(SListView *view,int scroll);
void slistview_show(SListView *view);
void slistview_set_active(SListView *view,gboolean active);

//if duration = 0 ,no animate
void slistview_set_animate(SListView *view,int duration,int step);


SListIter *slistview_append_iter(SListView *,SListIter*);
gboolean slistview_remove_iter(SListView *,SListIter*);

//Prepend ,insert has bug.
SListIter *slistview_prepend_iter(SListView *,SListIter*);
gboolean slistview_insert_iter(SListView *,SListIter*,gint);
gboolean slistview_insert_iter_after(SListView *view,SListIter *iter,SListIter *after);
gboolean slistview_insert_iter_before(SListView *view,SListIter *iter,SListIter *before);

#endif
